import { Component } from '@angular/core';
import { Router, Params } from '@angular/router';


declare let $:any;

@Component({
    selector: 'app-header',
    templateUrl: '../../../views/header.html',
    styleUrls: ['../../../css/header.css']
})
export class HeaderComponent {
        public is_login:any;
        public login:any;
        public isHome:any;
        public homes:any;
        public object:any;
        public returns:any;
        public recharge:any;
        public user:any;
        public register:any;
        public GameDetails:any;
        public isProject:any = false;
        public isRecharge:any = false;
        public loginActive:any = false;
        public registerActive:any = false;
        public isSelect:any = false;

        constructor(
            private router : Router,
        ){
            this.login = $.cookie("phone");
            this.isSelect = $.cookie("home");
            console.log(this.isSelect);
            this.isLogin();
            switch (this.isSelect){
                case "1":
                    this.isHome = true;
                    this.isProject = false;
                    this.isRecharge = false;
                    this.loginActive = false;
                    this.registerActive = false;

                    this.homes = true;
                    this.object = false;
                    this.recharge = false;
                    this.returns = false;
                    this.user = false;
                    this.register = false;
                    this.GameDetails = false;
                    break;
                case "2":
                    this.isProject = true;
                    this.isHome = false;
                    this.isRecharge = false;
                    this.loginActive = false;
                    this.registerActive = false;

                    this.object = true;
                    this.homes = false;
                    this.recharge = false;
                    this.returns = true;
                    this.user = false;
                    this.register = false;
                    this.GameDetails = false;
                    break;
                case "3":
                    this.isRecharge = true;
                    this.isHome = false;
                    this.isProject = false;
                    this.loginActive = false;
                    this.registerActive = false;

                    this.recharge = true;
                    this.object = false;
                    this.homes = false;
                    this.returns = true;
                    this.user = false;
                    this.register = false;
                    this.GameDetails = false;
                    break;
                case "5":
                    this.loginActive = true;
                    this.isRecharge = false;
                    this.isHome = false;
                    this.isProject = false;
                    this.registerActive = false;

                    this.user = true;
                    this.recharge = false;
                    this.object = false;
                    this.homes = false;
                    this.returns = true;
                    this.register = false;
                    this.GameDetails = false;
                    break;
                case "6":
                    this.registerActive = true;
                    this.isRecharge = false;
                    this.isHome = false;
                    this.isProject = false;
                    this.loginActive = false;

                    this.register = true;
                    this.user = false;
                    this.recharge = false;
                    this.object = false;
                    this.homes = false;
                    this.returns = true;
                    this.GameDetails = false;
                    break;
                case "7":
                    this.GameDetails = true;
                    this.user = false;
                    this.recharge = false;
                    this.object = false;
                    this.homes = false;
                    this.returns = true;
                    this.register = false;
                    break;
            }
        }

        public isLogin(){
            let self:any = this;
            if(this.login == "null" || this.login == null){
                this.is_login = false;
            }else {
                this.is_login = true;
            }
            console.log(this.is_login);
        }
        public quit(){
            $.cookie('phone', null);
            $.cookie('id', null);
            $.cookie('money', null);
            $.cookie('username', null);
            $.cookie('avatar', null);
            $.cookie('avatar_path', null);
            $.cookie('has_mp', null);
            this.router.navigate(['/login']);
        }
        //汉堡包导航
        public navShow(){
            /*$(".hidden_nav").slideToggle("slow");*/
            if($(".hidden_nav").is(":hidden")){
                $(".hidden_nav").show("1000");
            }
            else{
                $(".hidden_nav").hide("1000");
            }
        }
        //得到当前标题
        public  return(){
            history.back(-1);
        }
        public select(n: any){
            console.log(n);
        }

}
